package com.haiyangwang1.lesson4;
class cat extends Animal{
    public void eat(){
        System.out.println("小猫咪爱吃鱼");
    }
}
class dog extends Animal{
    public void eat(){
        System.out.println("小狗爱啃骨头");
    }
}
class Bird extends Animal{
    public void eat(){
        System.out.println("小鸟爱吃虫子");
    }
}
class feeder{
    public void feed(Animal animal){
        animal.eat();
    }
}
public class Animal {
    public void eat(){
        System.out.println("动物都要吃东西");
    }

    public static void main(String[] args) {
        Animal[] animal=new Animal[5];
        cat c=new cat();
        animal[0]=c;
        dog d=new dog();
        animal[1]=d;
        cat c1=new cat();
        animal[2]=c1;
        dog d1=new dog();
        animal[3]=d1;
        Bird b=new Bird();
        animal[4]=b;
        feeder f=new feeder();

        for (int i=0;i<animal.length;i++){
            f.feed(animal[i]);
        }

    }
}
